/**
 * Software License Declaration.
 * <p>
 * wandaph.com, Co,. Ltd.
 * Copyright ? 2017 All Rights Reserved.
 * <p>
 * Copyright Notice
 * This documents is provided to wandaph contracting agent or authorized programmer only.
 * This source code is written and edited by wandaph Co,.Ltd Inc specially for financial
 * business contracting agent or authorized cooperative company, in order to help them to
 * install, programme or central control in certain project by themselves independently.
 * <p>
 * Disclaimer
 * If this source code is needed by the one neither contracting agent nor authorized programmer
 * during the use of the code, should contact to wandaph Co,. Ltd Inc, and get the confirmation
 * and agreement of three departments managers  - Research Department, Marketing Department and
 * Production Department.Otherwise wandaph will charge the fee according to the programme itself.
 * <p>
 * Any one,including contracting agent and authorized programmer,cannot share this code to
 * the third party without the agreement of wandaph. If Any problem cannot be solved in the
 * procedure of programming should be feedback to wandaph Co,. Ltd Inc in time, Thank you!
 */
package com.varton.filter;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author lihuazeng
 * @version Id: Main.java, v 0.1 2019/1/24 15:59 lihuazeng Exp $$
 */
public class Main {
    public static void main(String[] args) {
        List<Person> personList = new ArrayList<>();
        personList.add(new Person("b1", 21));
        personList.add(new Person("b2", 15));

        personList.add(new Person("a1", 15));
        personList.add(new Person("a2", 20));
        personList.add(new Person("c1", 19));


        List<Criteria> cs = new ArrayList<>();
        cs.add(new AgeCriteria());
        cs.add(new NameCriteria());

        Criteria or = new OrCriteria(cs);
        Criteria and = new AndCriteria(cs);

        List<Person> ps = or.meetPersons(personList);
        System.out.println(JSON.toJSONString(ps));

        ps = and.meetPersons(personList);
        System.out.println(JSON.toJSONString(ps));
    }
}